package io.hepu.robotize.model;

import io.hepu.robotize.aop.RedisId;
import io.hepu.robotize.base.BaseEntity;
import io.hepu.robotize.service.impl.PermissionService;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

import javax.persistence.Column;
import javax.persistence.Table;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

@ApiModel(value = "权限")
@Table(name = "tb_permission")
@RedisId(id = 904000000001L, table = "tb_permission", provider = PermissionService.class)
public class Permission extends BaseEntity<String> implements Serializable {
    @ApiModelProperty(value = "权限名称")
    @Column(name = "name")
    private String name;

    @ApiModelProperty(value = "权限编码")
    @Column(name = "code")
    private String code;

    @ApiModelProperty(value = "上级权限")
    @Column(name = "parent_id")
    private String parentId;

    @ApiModelProperty(value = "权限类型")
    @Column(name = "type")
    private Integer type;

    @ApiModelProperty(value = "权限地址")
    @Column(name = "uri")
    private String uri;

    @ApiModelProperty(value = "图标")
    @Column(name = "icon")
    private String icon;

    @ApiModelProperty(value = "排序")
    @Column(name = "sort")
    private Integer sort;

    @ApiModelProperty(value = "状态")
    @Column(name = "status")
    private Integer status;

    @ApiModelProperty(value = "权限描述")
    @Column(name = "remark")
    private String remark;

    @ApiModelProperty(value = "子权限")
    private List<Permission> children = new ArrayList<>();

    @ApiModelProperty(value = "是否含子权限")
    private boolean hasChildren;

    private static final long serialVersionUID = 1L;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name == null ? null : name.trim();
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code == null ? null : code.trim();
    }

    public String getParentId() {
        return parentId;
    }

    public void setParentId(String parentId) {
        this.parentId = parentId == null ? null : parentId.trim();
    }

    public Integer getType() {
        return type;
    }

    public void setType(Integer type) {
        this.type = type;
    }

    public String getUri() {
        return uri;
    }

    public void setUri(String uri) {
        this.uri = uri == null ? null : uri.trim();
    }

    public String getIcon() {
        return icon;
    }

    public void setIcon(String icon) {
        this.icon = icon == null ? null : icon.trim();
    }

    public Integer getSort() {
        return sort;
    }

    public void setSort(Integer sort) {
        this.sort = sort;
    }

    public Integer getStatus() {
        return status;
    }

    public void setStatus(Integer status) {
        this.status = status;
    }

    public String getRemark() {
        return remark;
    }

    public void setRemark(String remark) {
        this.remark = remark == null ? null : remark.trim();
    }

    public List<Permission> getChildren() {
        return children;
    }

    public void setChildren(List<Permission> children) {
        this.children = children;
    }

    public boolean isHasChildren() {
        return hasChildren;
    }

    public void setHasChildren(boolean hasChildren) {
        this.hasChildren = hasChildren;
    }
}
